package com.example.smartcanteen.controller;

import com.example.smartcanteen.model.Goods;
import com.example.smartcanteen.model.Shop;
import com.example.smartcanteen.service.GoodsService;
import com.example.smartcanteen.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
@CrossOrigin
public class GoodsController {
    @Autowired
    private GoodsService goodsService;


    //商品上架 所需数据：int shopID：String goodsname；double：price；String taste；
    @PostMapping("/grounding")
    ResponseMessage grounding(Goods goods) {


        return goodsService.grounding(goods);
    }


    // 查看所以商品（管理员适用）
    @PostMapping("/selectAll")
    ResponseMessage selectAll() {


        return goodsService.selectAll();
    }


    //查看店内所有商品（学生适用）
    @PostMapping("/selectAllSG")
    ResponseMessage selectAllSG(Integer shopID){


        return goodsService.selectAllSG(shopID);
    }


    //查看店内所有状态商品（商家适用）
    @PostMapping("/selectAllSSG")
    ResponseMessage selectAllSSG(Integer shopID){


        return goodsService.selectAllSSG(shopID);
    }
}
